<template>
  <div class="public_main">
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>{{$t('dashBoard.no19')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('dashBoard.no12')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('dashBoard.no15')}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>

    <!-- -------------搜索查询栏------------------------ -->
    <search 
      :searchData="searchData" 
      @search="search" 
      :searchRight="true"
    ></search>

    <!-- -------------表单显示栏------------------------ -->
    <div class="table" >
      <template>
        <el-table :data="tableData" stripe size="small" >
          <el-table-column align="center" prop="orderNo" :label="$t('public.orderNo')">
          </el-table-column>
          <el-table-column align="center" prop="orderId" :label="$t('public.orderId')">
          </el-table-column>
          <el-table-column align="center" prop="userId" :label="$t('public.userId')">
          </el-table-column>
          <el-table-column align="center" prop="transactionId" :label="$t('finance.dealId')">
          </el-table-column>
          <el-table-column align="center" prop="userName" :label="$t('public.name')">
          </el-table-column>
          <el-table-column align="center" prop="loanType" :label="$t('finance.putMoneyType')">
            <template slot-scope="scope">
              <span>{{scope.row.loanType==1?$t('finance.putType.no1'):$t('finance.putType.no2')}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="phone" :label="$t('public.no18')">
          </el-table-column>
          <el-table-column align="center" prop="amount" :label="$t('finance.amount')">
            <template slot-scope="scope">
              <span>{{$store.state.common.id_currency}}{{$store.getters.moneySplit(scope.row.amount)}}{{$store.state.common.vi_currency}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="applyTime" :label="$t('public.CreateDate')" width="86">
          </el-table-column>
          <el-table-column align="center" prop="loanTime" :label="$t('finance.successDate')" width="86">
          </el-table-column>
          <el-table-column align="center" prop="thirdChannel" :label="$t('finance.channel')">
          </el-table-column>
          <el-table-column align="center" prop="bankType" :label="$t('yuenan.no18')">
          </el-table-column>
          <el-table-column align="center" prop="bankName" :label="$t('public.no19')">
            <!-- <template slot-scope="scope">
              <span v-if="scope.row.bankType!==null&&scope.row.bankType!==undefined&&scope.row.bankType==='NganLuong'">-</span>
              <span v-else>{{scope.row.bankName}}</span>
            </template> -->
          </el-table-column>
          <el-table-column align="center" prop="email" :label="$t('finance.account')">
            <!-- <template slot-scope="scope">
              <span v-if="scope.row.bankType!==null&&scope.row.bankType!==undefined&&scope.row.bankType==='NganLuong'">{{scope.row.email}}</span>
              <span v-else>{{scope.row.bankAccount}}</span>
            </template> -->
          </el-table-column>
          <el-table-column align="center" prop="status" :label="$t('finance.status')">
            <template slot-scope="scope">
              <span>{{$t($store.getters.putMoneyLogStatus(scope.row.status))}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="partnerName" :label="$t('merchantList.no1')"></el-table-column>
          <el-table-column align="center" prop="remark" :label="$t('public.no37')">
          </el-table-column>
        </el-table>
      </template>
    </div>

    <!-- ------------  分页显示栏  ------------------------ -->
    <el-row type="flex" justify="end">
      <div class="pages" >
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page="pagination.current"
          layout="sizes, prev, pager, next, total,->"
          :page-sizes="pagination.pageSizeOptions"
          :page-size="pagination.pageSize"
          @size-change="handleSizeChange"
          :total="pagination.total">
        </el-pagination>
      </div>
    </el-row>

    <div class="foot"></div>

  </div>
</template>
<script>
import getMerchant from 'src/mixins/getMerchant.js';
import getPayChannel from 'src/mixins/getPayChannel.js';//获取下拉通道
export default {
  name: 'putLogList',
  mixins: [getMerchant,getPayChannel],
  data () {
    const searchData=[
      {
        type: 'input',
        label: 'public.orderId',
        attr: 'orderId',
        value: ''
      },
      {
        type: 'input',
        label: 'public.orderNo',
        attr: 'orderNo',
        value: ''
      },
      {
        type: 'input',
        label: 'public.name',
        attr: 'userName',
        value: ''
      },
      {
        type: 'input',
        label: 'public.userTel',
        attr: 'phone',
        value: ''
      },
      {
        type: 'select',
        label: 'finance.channel',
        attr: 'thirdChannel',
        option: [],
        value: '',
        langFlag: false,
      },
      {
        type: 'select',
        label: 'public.no22',
        attr: 'status',
        option: this.$store.state.options.putMoneyLog_select,
        value: '',
        langFlag: true,
      },
      {
        type: 'select',
        label: 'finance.putMoneyType',
        attr: 'loanType',
        option: this.$store.state.options.putMoneyLog_putType,
        value: '',
        langFlag: true,
      },
      {
        type: 'select',
        label: 'merchantList.no1',
        attr: 'partnerId',
        option: [],
        value: '',
        langFlag: false,
      },
      {
        type: 'rangePicker',
        label: 'public.CreateDate',
        attr: 'applyTime',
        value: [],
      },
      {
        type: 'rangePicker',
        label: 'finance.createTime',
        attr: 'createTime',
        value: [],
      },
      {
        type: 'rangePicker',
        label: 'finance.successTime',
        attr: 'loanTime',
        value: [],
      },
    ]
    return {
      loadFlag: true,
      pagination: {
        pageSize: global.config.pageSize,
        pageSizeOptions: global.config.pageSizeOptions,
        current: 1,
        total: 0,
      },
      formInline: {},// 用户查询信息数据对应字段
      searchData:searchData,
      options1: this.$store.state.options.thirdChannel_vi, // 通道
      options2: this.$store.state.options.putMoneyLog_select, // 状态下拉选框信息
      options3: this.$store.state.options.putMoneyLog_putType, // 放款类型下拉选框信息
      options4: [], // 商户列表下拉框数据
      tableData: []// 用户信息数据模拟
    }
  },
  methods: {
    handleSizeChange (val) {// 每页条数变化时操作
      this.pagination.pageSize = val;
      this.getTableData();
    },
    handleCurrentChange (val) { // 分页按钮点击操作
      this.pagination.current = val;
      this.getTableData();
    },
    search (search) { // 查询按钮点击操作
      this.formInline = {
        orderNo:search.orderNo,
        orderId: search.orderId,
        userName:search.userName,
        phone: search.phone,
        thirdChannel: search.thirdChannel,
        applyTimeBegin: search.applyTime?search.applyTime[0]:'',
        applyTimeEnd: search.applyTime?search.applyTime[1]:'',
        createTimeBegin: search.createTime?search.createTime[0]:'',
        createTimeEnd: search.createTime?search.createTime[1]:'',
        loanTimeBegin: search.loanTime?search.loanTime[0]:'',
        loanTimeEnd:search.loanTime?search.loanTime[1]:'',
        status: search.status,
        loanType:search.loanType,
        partnerId:search.partnerId,
      };
      this.pagination.current = 1;
      this.getTableData();
    },
    getTableData () { // 列表数据获取
      this.loadFlag = true;
      let option = {
        pageNum:this.pagination.current,
        pageSize:this.pagination.pageSize,
        param: {
          ...this.formInline
        }       
      }
      this.$axios.post(this.$action.pay_loan_list, option).then(res => {
        if (res.code == 200) {
          this.tableData = res.data.list;
          this.pagination.total = res.data.total;
        }else{
          this.$globalMsg.error(res.message)
        }
        this.loadFlag = false;
      })
    },
    putExcel () { // excel下载
      if (this.flag) {
        this.flag = false
        let option = {
          header: {
            ...this.$base,
            action: this.$action.putMoney_logExcel,
            'page': {'index': this.currentPage, 'size': this.pageNumber},
            'sessionid': this.sessionid
          },
          ...this.formInline
        }
        this.$axios.post('', option).then(res => {
          this.flag = true;
          if (res.data.header.code == 0) {
            window.location.href = res.data.data.fileName;
          }
        })
      }
    },
    getChannelData(){//获取借款放款渠道下拉框数据
      let option = {
        param:{
          channelType: 3
        }
      }
      this.$axios.post(this.$action.channel_list, option).then(res => {
        if (res.code == 200) {
          let arr = []
          res.data.forEach(item=>{
            arr.push({value:item.channelName,label:item.channelName})
          })
          this.searchData.filter(value=>value.attr=='thirdChannel')[0].option = arr
				}
      })
    },
  },
  watch: {
  },
  mounted () {
    this.getTableData();
    this.getMerchant().then(data=>{
      this.searchData.filter(value=>value.attr=='partnerId')[0].option = data
    })
    this.getChannelData()
    
  }
}
</script>
<style scoped lang="scss">

</style>
